package bible.sunflower.web.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import bible.sunflower.util.upload.FileUploadByApache;

public class FileUploadController extends MultiActionController {
	
    Logger log = Logger.getLogger( FileUploadController.class );
	
	public ModelAndView index(HttpServletRequest req, HttpServletResponse resp){
		log.debug("start to receive upload files...");
		try {
			FileUploadByApache.upload(req, "/home/upload/");
			PrintWriter writer = resp.getWriter();
			writer.write("OK");
			writer.flush();
		} catch (Exception e) {
			log.error("upload file error", e);
		}
		return null;
	}

}
